-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically emit rustc-check-cfg
directives for AutoCfg
#70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this!
It would be nice to have a full test of this in CI, but it would need a real crate to get Cargo etc. to use it. If you're up for it, I'd create one or more nested crates under ci/
that exercise this, probably denying unexpected_cfgs
with both positive and negative cases. Then invoke those in the CI workflow, not recursive cargo test
or anything. :)
Per request of @cuviper in PR cuviper#70
I have verified that commit 027f73a makes |
Curious, the CI failure looks like a compiler race condition that's unlikely to be caused by your change. I can't reproduce it locally though... |
Oh, that was #65, but this is the first time I've seen it here in CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggesting minor tweaks for older versions in that CI crate.
This avoids the `unexpected_cfgs` lint for any of the configs emitted by AutoCfg methods. This lint is new in Rust 1.80: <https://blog.rust-lang.org/2024/05/06/check-cfg.html> This adds a `emit_possibility` method to mirror the `emit` method. Calling `emit` manually does not call `emit_possibility`. Fixes issue cuviper#64
Misisng link and incorrect `cargo:cargo:...` prefix
Per request of @cuviper in PR cuviper#70
I can't use rust 1.0 on my computer (M1 Mac), so I am relying on CI to check this.
3aec0a2
to
52a995b
Compare
Thank you! 😁 |
There is a bug in the current CI suite with autocfg that was fixed in cuviper/autocfg#70 (autocfg 1.4+). Rust 1.80 introduced a new lint that was causing the build to fail on CI. I deleted the lockfile and reinstalled and that fixed the issue. Previously the failure on CI looked like this: ``` Run actions-rs/cargo@v1 /home/runner/.cargo/bin/cargo test Downloading crates ... Downloaded itoa v1.0.[9](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:10) Downloaded serde v1.0.192 Downloaded ryu v1.0.15 Downloaded serde_json v1.0.[10](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:11)0 Compiling serde v1.0.192 Compiling serde_json v1.0.100 Compiling ryu v1.0.15 Compiling itoa v1.0.9 warning: unexpected `cfg` condition name: `rustc_1_63` --> src/path.rs:16:[11](https://github.com/andrewhickman/fs-err/actions/runs/11391081315/job/31694081963?pr=61#step:6:12) | 16 | #[cfg(rustc_1_63)] | ^^^^^^^^^^ | = help: expected names are: `clippy`, `debug_assertions`, `doc`, `docsrs`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows` = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(rustc_1_63)'] } = help: or consider adding `println!("cargo::rustc-check-cfg=cfg(rustc_1_63)");` to the top of the `build.rs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default ```
This avoids the
unexpected_cfgs
lint for any of the configs emitted by AutoCfg methods.This lint is new in Rust 1.80: https://blog.rust-lang.org/2024/05/06/check-cfg.html
This adds a
emit_possibility
method to mirror theemit
method.Calling
emit
manually does not callemit_possibility
.Fixes issue #64